// vp/vp_sc/pages/index/index.js
var app = getApp();
var vp = require('../../resource/js/vp.js');

const innerAudioContext = wx.createInnerAudioContext();

Page({

        /**
         * 页面的初始数据
         */
        data: {
                signed:null,
                _signModal:false,

                _shareModal:false,

                addmy:false,

                cat:'',
                start: 0,
                more: 1,
                list: null,
                is_loading_more: false,
        },



        /**
         * 生命周期函数--监听页面加载
         */
        onLoad: function (options) {
                  },

        onReady: function () {

  
                var self = this;

                var addmy = wx.getStorageSync('vp_pz_sharer_addmy');
                this.setData({
                        addmy:addmy?false:true
                });

  
        },

        /**
         * 生命周期函数--监听页面显示
         */
        onShow: function () {
                var self=this;

                console.log("----");
                this.main_load(false);
        },

        /**
         * 生命周期函数--监听页面隐藏
         */
        onHide: function () {

        },

        /**
         * 生命周期函数--监听页面卸载
         */
        onUnload: function () {

        },


        /**
         * 分享
        */
        onShareAppMessage: function () {
                console.log(this.getSharePath());
                return {
                        title: this.data.cfg.share_title?this.data.cfg.share_title:this.data.cfg.name,
                        imageUrl: this.data.cfg.share_image_url,
                        path: this.getSharePath()
                }
        },
        // onShareTimeline:function(){
        //     return {
        //         title: this.data.cfg.share_title?this.data.cfg.share_title:this.data.cfg.name,
        //         imageUrl: this.data.cfg.logo_url,
        //         query:  'aid='+this.data.area.id+'&fuid=' + this.data.mine.id
        //     }
        // },
        getSharePath:function(){
                var page = app.mdName + '/pages/index/index';
                var ps = '?aid='+this.data.area.id+'&fuid=' + this.data.mine.id
                return page + ps;
        },

        showShareModal(){
                this.setData({_shareModal:true});
        },

        // 前往医院
        toHospital:function(e){
                wx.navigateTo({
                        url: '../kjyl/hospital?hid='+e.currentTarget.dataset.hid,
                })
        },


        // 页面数据加载
        main_load(showLoading) {
                const self = this;
                //console.log("self.data.like "+self.data.like);
                app.util.request({
                        url: 'Hospital/kuajinglists',
                        showLoading: showLoading ? true : false,
                        data: {
                                m: app.mdName
                        },
                        complete(res) {
                        wx.stopPullDownRefresh();
                        },
                        success(res) {
                                var data = res.data.data;
								console.log(data)
                                self.setData({
                                        main_loaded: true,
                                        now:data.now,
                                        hospitals:data.hospital,
                                });
                        }
                })
        },

        makePhoneCall:function(e){
                wx.makePhoneCall({
                        phoneNumber: e.currentTarget.dataset.tel
                });
        },


        closeAddmy(){
                this.setData({
                        addmy:false
                });
                wx.setStorage({
                        key:"vp_pz_sharer_addmy",
                        data:true
                });
        },

        
})